package Time918;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import util.Common;

public class Gradedao {
	public List<Grade> get() {
		List<Grade> gl = new ArrayList<Grade>();
		String sql = "select * from grade ";
		Connection con = Common.getConnection();
		PreparedStatement ps = null;
		ResultSet rs = null;

		Grade g = null;
		try {
			ps = con.prepareStatement(sql);

			rs = ps.executeQuery();
			while (rs.next()) {
				g = new Grade();
				g.setId(rs.getInt("id"));
				g.setGname(rs.getString("gname"));
				gl.add(g);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			Common.close(con, ps, rs);
		}

		return gl;
	}
}
